package com.efruit.shopcart;

public class ShoppingItem {
	private IProductInfo productInfo;
	private int amount;

	protected ShoppingItem(IProductInfo productInfo, int amount) {
		this.productInfo = productInfo;
		this.amount = amount;
	}

	public ShoppingItem(ShoppingItem item) {
		productInfo.setId(item.getId());
		productInfo.setName(item.getName());
		productInfo.setPrice(item.getPrice());
		amount = item.getAmount();
	}

	public int getAmount() {
		return amount;
	}
	
	public int getId(){
		return productInfo.getId();
	}
	
	public String getName(){
		return productInfo.getName();
	}
	
	public float getPrice(){
		return productInfo.getPrice();
	}
	
	protected IProductInfo getIProductInfo(){
		return productInfo;
	}

	/**
	 * @param amount
	 *            the amount of product
	 * @return false if amount is smaller than 1
	 */
	protected boolean setAmount(int amount) {
		if (amount <= 0) {
			System.err.println("amount should be any int greater than 0");
			return false;
		}
		this.amount = amount;
		return true;
	}

}
